<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Yy</title>
</head>

<body>
    <script>
        // 1. 扩展Date对象实现如下功能，实现dateFormate方法，返回值是“xxxx年xx月xx日”
        Date.prototype.dateFormate = function() {
            let year = this.getFullYear();
            let month = this.getMonth();
            let date = this.getDate();
            return `${year}年${month + 1}月${date}日`;
        }
        let d = new Date("2020-2-2");
        let result = d.dateFormate();
        console.log(result);
        console.log("--------------");
        // 2. 定义一个Person类，让Student类和Teacher类继承Person，
        // 为Person类添加getInformation方法，使Student类和Teacher类都可以通过此方法获取个人信息。
        class Person {
            constructor(name, age) {
                this.name = name;
                this.age = age;
            }
            getInformation() {
                console.log(`我是${this.name}，我今年${this.age}岁`);
            }
        }
        class Student extends Person {
            constructor(name, age) {
                super(name);
                this.age = age;
            }
        }

        class Teacher extends Person {
            constructor(name, age) {
                super(name);
                this.age = age;
            }
        }
        let a = new Student("Dog", 17);
        let b = new Teacher("Cat", 18);
        a.getInformation();
        b.getInformation();
    </script>
</body>

</html>